#include "ExampleInteractable.h"

namespace Tutorial2
{
	/**
	Constructor
	*/
	ExampleInteractable::ExampleInteractable() :
		Interactable()
	{
		setScale(0.2f);
	}

	/**
	Destructor
	*/
	ExampleInteractable::~ExampleInteractable()
	{
	}

	/**
	* Loads the graphics to be used by interactable
	* \param inApplicationDir Path to the Applications data folder
	*/
	void ExampleInteractable::load(const QString& inApplicationDir)
	{
		// load the sprite
		mSprite.load(inApplicationDir+"Home.png");
	}

	/**
	* Unloads the loaded graphics
	*/
	void ExampleInteractable::unload()
	{
		mSprite.unload();
	}

	/**
	Draw method
	*/
	void ExampleInteractable::draw()
	{
		// update the sprites properties
		mSprite.setPosition(getPosition());
		mSprite.setScale(getScale());
		mSprite.setRotation(getRotation());

		// render the sprite
		mSprite.render();
	}

	/**
	Method for checking if the input is inside the interactable's area.
	\param inBlob the fingerData
	\return bool if the fingerData is inside or not.
	*/
	bool ExampleInteractable::isInside(const TouchListener::TouchData &inBlob)
	{
		QVector2D fingerPos(inBlob.mX, inBlob.mY);
		QVector2D size(mSprite.getWidth(), mSprite.getHeight());
		QVector2D pos = getPosition();
		return Blobz::pointInOrientedRectangle(fingerPos, pos, size, getRotation());
	}
}